package cn.wolfcode.shop.server.service.impl;

import cn.wolfcode.shop.api.domain.CatalogPropertyValue;
import cn.wolfcode.shop.api.service.ICatalogPropertyValueService;
import cn.wolfcode.shop.server.mapper.CatalogPropertyValueMapper;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

@Service
public class CatalogPropertyValueServiceImpl implements ICatalogPropertyValueService {

    @Autowired
    private CatalogPropertyValueMapper catalogPropertyValueMapper;

    public void delete(Long id) {
        catalogPropertyValueMapper.delete(id);
    }

    public void save(Long catalogPropertyId, String[] values) {
        if(values == null){
            return;
        }
        CatalogPropertyValue value = new CatalogPropertyValue();
        for (int i = 0; i < values.length; i++) {
            value.setCatalogPropertyId(catalogPropertyId);
            value.setValue(values[i]);
            catalogPropertyValueMapper.save(value);
        }
    }
}
